<template>
  <div>
    <h2>子组件</h2>
    <p>父组件传递的name: {{ name }}</p>
    <button @click="handClick">改变name</button>
    <hr />
    <Child2 v-bind="$attrs" v-on="$listeners"></Child2>
  </div>
</template>

<script>
import Child2 from './Child2.vue'
export default {
  name: 'Child',
  components: { Child2 },
  props: ['name'], // 这里可以接收，也可以不接收
  methods: {
    handClick() {
      // this.$emit('changName', '李四')
      this.$listeners.changName('李四')
    }
  },
  mounted() {
    // 如果props接收了name 就是 { title:标题 }，否则就是{ name:"张三",  title:标题}
    console.log('1111:', this.$attrs)
    console.log('3333:', this.$listeners)
  }
}
</script>

<style lang="scss" scoped></style>
